Closed
Conversation
Add default_api_level=API_HYBRID to protoc-gen-go options to enable the Hybrid API. This generates both Open struct and Opaque API files, allowing gradual migration of code to use accessor methods (Set*, Get*, Has*, Clear*) instead of direct field access. The Hybrid API: - Adds accessor methods to existing Open struct messages - Generates *_protoopaque.pb.go files with hidden fields - Enables lazy decoding and memory optimizations when fully migrated See: https://go.dev/blog/protobuf-opaque Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
stephanos
commented
Jan 24, 2026
| args = append(args, fmt.Sprintf("--go_out=paths=source_relative:%s", cfg.outputDir)) | ||
| // Enable Hybrid API for gradual migration to Opaque API | ||
| // See: https://go.dev/blog/protobuf-opaque | ||
| args = append(args, "--go_opt=default_api_level=API_HYBRID") |
Contributor
Author
There was a problem hiding this comment.
This is the only manual change.
…e API
- Convert all serviceerror files to use Type_builder{}.Build() pattern
- Fix gateway files to use setters instead of direct field assignment
- Update convert.go for multi-operation error handling
- Various other opaque API compatibility fixes
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update the interceptor template to generate code compatible with
protobuf opaque API:
- Use GetPayloads()/SetPayloads() instead of direct field access
- Use Has{{Field}}() for nil checks on payload fields
- Use Get{{Field}}()/Set{{Field}}() for payload field access
Regenerate proxy/interceptor.go with updated template.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add default_api_level=API_HYBRID to protoc-gen-go options to enable the Hybrid API.
This generates both Open struct and Opaque API files, allowing gradual migration of code to use accessor methods (Set*, Get*, Has*, Clear*) instead of direct field access.
See: https://go.dev/blog/protobuf-opaque